﻿<%@ Control Language="C#" AutoEventWireup="true" Codebehind="Lookup.ascx.cs" Inherits="CMS.Web.Lookups.Lookup" %>
<script language="javascript" src="Common/paging.js"></script>

<table id="tbl" class="Table_Border" style="border-collapse: collapse" cellspacing="0"
    cellpadding="0" width="90%" border="0" align="center">
    <tr valign="top">
        <td valign="top" align="center" height="40px" class="Title">
            TRA CỨU DỮ LIỆU ĐƠN THƯ</td>
    </tr>
    <tr>
        <td width="100%">
            <table id="tblThongTinChung" class="Grid_Border"
                cellspacing="0" cellpadding="3" width="100%" border="0">
                <tbody>
                    <tr>
                        <td valign="middle" align="left" class="Col_Left">
                            Tìm kiếm cho</td>
                        <td class="Col_Right" valign="middle" colspan="2">
                            <input type="radio" id="radStatus1" name="radStatus" value="True" checked>Tất cả
                            <input type="radio" id="radStatus2" name="radStatus" value="False">Một trong các
                            điều kiện sau                            
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="left" class="Col_Left">
                            Thuộc tính ký tự</td>
                    </tr>
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">Lĩnh vực:</TD>
			            <td class="Col_Right" colspan="2">
			        	    <asp:DropDownList ID="drpLinhVuc" runat="server" Height="22" CssClass="TextBox" Width="36%" DataValueField="ID" DataTextField="TenLinhVuc">
			        	        <asp:ListItem Selected = "True" Text = "" Value = ""></asp:ListItem>
			        	    </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
		                <td class="Col_Left" style="padding-left: 10px">Loại đơn:</TD>
			            <td class="Col_Right" colspan="2">
			        	    <asp:DropDownList ID="drpLoaiDon" runat="server" Height="22" CssClass="TextBox" Width="36%" DataValueField="ID" DataTextField="TenLoaiDon"></asp:DropDownList>
                        </td>                        
                    </tr>
                     <tr>
                        <td class="Col_Left" style="padding-left: 10px;">
                            Địa bàn:
                        </td>
                        <td class="Col_Right" align="left" colspan="2">
			                <asp:textbox id="drpDiaBan" runat="server" CssClass="TextBox" Width="67%" MaxLength="250" ReadOnly="true"></asp:textbox>
			                <img src="Images/scroll2.png" style="display:; cursor: pointer; cursor: hand;" onclick="openSelectDiaBanWindow('<% =drpDiaBan.ClientID%>','<%=hidDiaBan.ClientID %>');" />
			                <asp:HiddenField ID="hidDiaBan" runat="server" Value="0"/>
			            </td>
                    </tr>
                    <!-- Điều kiện 1 -->
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">
                            <select id="cmbField1" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="TenChuDon1" value="HoTen">Tên chủ đơn</option>
                                <option id="NoiDung1" value="NoiDung">Nội dung đơn</option>
                                <option id="DiaChi1" value="DiaChi">Địa chỉ</option>
                                <option id="KetQua1" value="KetQuaGiaiQuyet">Kết quả giải quyết</option>
                            </select>
                        </td>
                        <td class="Col_Right" colspan="2">
                            <asp:TextBox ID="txtField1" runat="server" MaxLength="100" Width="84%" CssClass="TextBox"></asp:TextBox>
                        </td>
                    </tr>
                    <!-- Điều kiện 2 -->
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">
                            <select id="cmbField2" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="TenChuDon2" value="HoTen">Tên chủ đơn</option>
                                <option id="NoiDung2" value="NoiDung">Nội dung đơn</option>
                                <option id="DiaChi2" value="DiaChi">Địa chỉ</option>
                                <option id="KetQua2" value="KetQuaGiaiQuyet">Kết quả giải quyết</option>
                            </select>
                        </td>
                        <td class="Col_Right" colspan="2">
                            <asp:TextBox ID="txtField2" runat="server" MaxLength="100" Width="84%" CssClass="TextBox"></asp:TextBox>
                        </td>
                    </tr>
                    <!-- Điều kiện 3 -->
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">
                            <select id="cmbField3" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="TenChuDon3" value="HoTen">Tên chủ đơn</option>
                                <option id="NoiDung3" value="NoiDung">Nội dung đơn</option>
                                <option id="DiaChi3" value="DiaChi">Địa chỉ</option>
                                <option id="KetQua3" value="KetQuaGiaiQuyet">Kết quả giải quyết</option>
                            </select>
                        </td>
                        <td class="Col_Right" colspan="2">
                            <asp:TextBox ID="txtField3" runat="server" MaxLength="100" Width="84%" CssClass="TextBox"></asp:TextBox>
                        </td>
                    </tr>
                    <!-- Điều kiện 4 -->
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">
                            <select id="cmbField4" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="TenChuDon4" value="HoTen">Tên chủ đơn</option>
                                <option id="NoiDung4" value="NoiDung">Nội dung đơn</option>
                                <option id="DiaChi4" value="DiaChi">Địa chỉ</option>
                                <option id="KetQua4" value="KetQuaGiaiQuyet">Kết quả giải quyết</option>
                            </select>
                        </td>
                        <td class="Col_Right" colspan="2">
                            <asp:TextBox ID="txtField4" runat="server" MaxLength="100" Width="84%" CssClass="TextBox"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="left" class="Col_Left">
                            Thuộc tính ngày</td>
                    </tr>
                    <!-- So sánh kiểu ngày -->
                    <tr>
                        <td class="Col_Left" width="22%" style="padding-left: 10px">
                            <select id="cmbDateField1" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="NgayVietDon1" value="DonDeNgay">Ngày viết đơn</option>
                                <option id="NgayGuiDon1" value="NgayGui">Ngày gửi đơn</option>
                            </select>
                        </td>
                        <td class="Col_Left" width="7%">
                            <select id="cmbDateCondition1" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="Bang1" value="=">=</option>
                                <option id="LonHon1" value=">">></option>
                                <option id="NhoHon1" value="<"><</option>
                            </select>
                        </td>
                        <td class="Col_Right" width="71%">
                            <asp:TextBox id="txtNgay1" runat="server" MaxLength="10" Width="30%" CssClass="TextBox"></asp:TextBox>
                            &nbsp;<img align="absmiddle" style="width:13px;cursor:pointer;" id="imgCal1" src="Images/icon.gif" alt="" /> 
                        </td>
                    </tr>
                    <tr>
                        <td class="Col_Left" style="padding-left: 10px">
                            <select id="cmbDateField2" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="NgayVietDon2" value="DonDeNgay">Ngày viết đơn</option>
                                <option id="NgayGuiDon2" value="NgayGui">Ngày gửi đơn</option>
                            </select>
                        </td>
                        <td class="Col_Left">
                            <select id="cmbDateCondition2" class="TextBox" style="width:90%; height:22px;">
                                <option value=""></option>
                                <option id="Bang2" value="=">=</option>
                                <option id="LonHon2" value=">">></option>
                                <option id="NhoHon2" value="<"><</option>
                            </select>
                        </td>
                        <td class="Col_Right">
                            <asp:TextBox id="txtNgay2" runat="server" MaxLength="10" Width="30%" CssClass="TextBox"></asp:TextBox>
                            &nbsp;<img align="absmiddle" style="width:13px;cursor:pointer;" id="imgCal2" src="Images/icon.gif" alt="" />                            
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" align="left" class="Col_Left">
                            Thuộc tính số
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3" style="padding-left: 10px" class="Col_Left">
                            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                                <tr>
                                    <td width="20%" align="left">
                                        Số thụ lý:
                                    </td>
                                    <td width="7%" align="right">
                                        Từ
                                    </td>
                                    <td width="25%" align="center">
                                        <asp:TextBox id="txtMinSoThuLy" runat="server" MaxLength="8" CssClass="TextBox" Width="85%"></asp:TextBox>
                                    </td>
                                    <td width="7%" align="center">
                                        Đến
                                    </td>
                                    <td width="25%" align="center">
                                        <asp:TextBox id="txtMaxSoThuLy" runat="server" MaxLength="8" CssClass="TextBox" Width="85%"></asp:TextBox>
                                    </td>
                                    <td width="16%">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td width="18%">
                        </td>
                        <td colspan="2" align="left" style="padding-top: 10px">
                            <input type="button" class="Button" value="Tìm kiếm" onclick="findDocuments();" />
                            <input type="reset" class="Button" value="Nhập lại" style="width: 90px;" language="javascript" onclick="resetValue();"/>
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
    </tr>
    <tr>
        <td class="Text_Main" height="30px" valign="middle">
            &nbsp;&nbsp;Kết quả: <span id="dt_Count" class="Document_Total">0</span> đơn thư
        </td>
    </tr>
    <!-- Ket qua -->
    <tbody id="tbdResults" style="display: none" valign="top">        
        <tr valign="top">
            <td class="Col_Right" align="left" height="200px" valign="top" width="100%">
                <table id="tblList" class="Grid_Border" cellspacing="0" cellpadding="3" width="100%" border="0">
                    <tr class="Row_Document_Title">
                        <td width="10%" align="center">
                            Số thụ lý
                        </td>
                        <td width="20%" align="left">
                            Người viết đơn
                        </td>
                        <td width="20%" align="left">
                            Địa chỉ
                        </td>
                        <td width="12%" align="center">
                            Ngày viết đơn
                        </td>
                        <td width="17%" align="left">
                            Loại đơn
                        </td>
                        <td width="16%" align="left">
                            Lĩnh vực
                        </td>
                        <td width="5%" align="center">
                        
                        </td>
                    </tr>
                    <tbody id="dt_Body" style="display: none">
                        <tr id="dt_Pattern" style="display: none">
                            <td id="soThuLy" style="height: 19px">
                            </td>
                            <td id="hoTen" style="height: 19px">
                            </td>
                            <td id="diaChiNguoiGui" style="height: 19px">
                            </td>
                            <td id="donDeNgay" align="center" style="height: 19px">
                            </td>
                            <td id="loaiDon" style="height: 19px">
                            </td>
                            <td id="linhVuc" style="height: 19px">
                            </td>
                            <td id="EDIT" style="height: 19px">
                            
                            </td>
                        </tr>
                        <tr id="dt_Page">
                            <td colspan="6">
                            </td>
                            <td id="display_Paging" align="right" class="Paging_NotLink" colspan="2">
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
        <tr class="Row_Button">
            <td align="right">
                <input type="button" class="Button" value="Xem in" onclick="OpenPrinter()" />
            </td>
        </tr>
    </tbody>
</table>

<script language="javascript" type="text/javascript">  
    var cmbField1, cmbField2, cmbField3, cmbField4;
    var cmbDateField1, cmbDateField2;
    var cmbDateCondition1, cmbDateCondition2;
    var txtField1 = "", txtField2 = "", txtField3 = "", txtField4 = "";
    var txtNgay1 = "", txtNgay2 = "";
    var txtMinSoThuLy = 0, txtMaxSoThuLy = 0;
    var searchType;
    var cmbLinhVuc = 0, cmbLoaiDon = 0, cmbDiaBan = 0;
    paging.recordsPerPage = 15;
    var resultCache = [];
    var cal1 = new Zapatec.Calendar({		
			lang   : "vn",
			inputField: "<%=txtNgay1.ClientID %>",
			ifFormat: "%d/%m/%Y",
			button: "imgCal1",
			theme: "aqua"
		});
     var cal2 = new Zapatec.Calendar({		
			lang   : "vn",
			inputField: "<%=txtNgay2.ClientID %>",
			ifFormat: "%d/%m/%Y",
			button: "imgCal2",
			theme: "aqua"
		});
    
    function findDocuments()
    {      
        paging.id = "dt_Page";
        paging.bodyId = "dt_Body";
        paging.patternId = "dt_Pattern";
        paging.filter = "";

        GetValueOfVars();         
       
        if (CheckValidation())
        {            
            CMS.Presenters.Presenters.LookupPresenter.TotalSearchDonThus(searchType, txtField1, txtField2, txtField3, txtField4,
                                txtNgay1, txtNgay2, txtMinSoThuLy, txtMaxSoThuLy, cmbLinhVuc, cmbLoaiDon, cmbDiaBan, function(response){
                if(response != null && response.value != null) 
                {                        
                    paging.totalRecords = response.value;                     
                    $('#dt_Count').html(paging.totalRecords);                       
                    $("#display_Paging").html(paging.limitPage(1, 0));                 
                    
                    if (response.value > 0)                    
                    {
                        renderList(1);
                        $("#" + paging.bodyId).attr("style", "display:");
                        $('#tbdResults').attr("style", "display:");                        
                    }
                    else
                    {
                        $('#dt_Count').html("0");
                        $("#" + paging.bodyId).attr("style", "display:none");
                        $('#tbdResults').attr("style", "display:none");  
                    }
                }
            });  
        }
    }
    
    function renderList(pageCurrent){
        var fromIndex = (pageCurrent > 1) ? (pageCurrent - 1) : 0;
        
        CMS.Presenters.Presenters.LookupPresenter.SearchDonThus(searchType, txtField1, txtField2, txtField3, txtField4,
                        txtNgay1, txtNgay2, txtMinSoThuLy, txtMaxSoThuLy, cmbLinhVuc, cmbLoaiDon, cmbDiaBan,
                        fromIndex*paging.recordsPerPage, paging.recordsPerPage, function(response)
        {
            subRenderList(response);
        });        
    }
    
    function subRenderList(response){
        $("#" + paging.patternId).attr("style", "display:none");
        util.removeAllRows(paging.bodyId, { filter:function(tr) {
            return (tr.id != paging.patternId && tr.id != paging.id);
        }});
        
        if(response.value != null)
        {            
            var dtList = response.value; 
            var cssClass = $("#" + paging.bodyId).attr("className");
            cssClass = "Row_Document_Odd";
            for (var i = 0; i < dtList.length; i++) { 
                var dt = {
                    ID: dtList[i][0],
                    SoThuLy: (dtList[i][1] + "/" + getYears(dtList[i][4])),
                    HoTen: dtList[i][2],
                    DiaChi: dtList[i][3],
                    DonDeNgay: dtList[i][4],
                    TenLoaiDon: dtList[i][5],
                    TenLinhVuc: dtList[i][6]
                }
                resultCache[dt.ID] = dt;
                util.cloneNode("dt_Pattern", { idSuffix:dt.ID }); 
                $("#soThuLy" + dt.ID).html(dt.SoThuLy);
                $("#hoTen" + dt.ID).html("<a onclick='ViewDetail(\""+ dt.ID +"\")' class='DocumentLink' href='#'>" + dt.HoTen + "</a>");                
                //$("#hoTen" + dt.ID).html(dt.HoTen);
                $("#diaChiNguoiGui" + dt.ID).html(dt.DiaChi);                
                $("#donDeNgay" + dt.ID).html(util.convertDateVN(dt.DonDeNgay));
                $("#loaiDon" + dt.ID).html(dt.TenLoaiDon);
                $("#linhVuc" + dt.ID).html(dt.TenLinhVuc);    
               if ($("#EDIT" + dt.ID)){
                $("#EDIT" + dt.ID).html("<%if (this.IsHuyDonThu()) { %><a class='Link-button' href=\"<%=FullBaseUrl%>default.aspx?tabID=1&fName=16&action=EDIT&objID="+ dt.ID +"\">" +
                        "<img src=\"Images/Icon_Compose.gif\" border=\"0\"/></a><%}%>");        
                        
                }
                             
                $("#" + paging.patternId + dt.ID).attr("className", cssClass);
                $("#" + paging.patternId + dt.ID).attr("style", "display:");  
                cssClass = (cssClass == "Row_Document_Round") ? "Row_Document_Odd" : "Row_Document_Round";     
            } 
        }
        
        $("#" + paging.bodyId).attr("style", "display:");
        $('#tbdResults').attr("style", "display:");
        //load_resize();
    }
    
    function gotoPage(pageCurrent, base) {  
        renderList(pageCurrent);
        pt = paging.limitPage(pageCurrent, base);
        $("#display_Paging").html(pt);
    }
    
    function ViewDetail(ID)
    {       
        var strType = "Lookups/ViewDetail.aspx";
        strFeatures = 'width=800px,height=600px,top=100px,left=100px,titlebar=1,menubar=0,toolbar=0,resizable=1,status=1,scrollbars=1,dependent=yes';        
        window.open(strType + "?ID=" + ID,'_blank',strFeatures);
        return false;
    }
    
    function GetValueOfVars()
    {           
        if ($("#radStatus1").attr("checked"))
        {
            searchType = "AND";
        }
        else
        {
            searchType = "OR";
        }        
        
        if ($("#<%=drpLinhVuc.ClientID%>").val() == "")
        {
            cmbLinhVuc = 0;
        } else {
            cmbLinhVuc = parseInt($("#<%=drpLinhVuc.ClientID%>").val());
        }
        
        if ($("#<%=drpLoaiDon.ClientID%>").val() == "")
        {
            cmbLoaiDon = 0;
        } else {
            cmbLoaiDon = parseInt($("#<%=drpLoaiDon.ClientID%>").val());
        }
        
        cmbDiaBan = parseInt($('#<%=hidDiaBan.ClientID %>').val());
        
        cmbField1 = $("#cmbField1").val();
        cmbField2 = $("#cmbField2").val();
        cmbField3 = $("#cmbField3").val();
        cmbField4 = $("#cmbField4").val();
        txtField1 = util.Trim($('#<%=txtField1.ClientID %>').val());
        txtField2 = util.Trim($('#<%=txtField2.ClientID %>').val());
        txtField3 = util.Trim($('#<%=txtField3.ClientID %>').val());
        txtField4 = util.Trim($('#<%=txtField4.ClientID %>').val());
        
        cmbDateField1 = $("#cmbDateField1").val();
        cmbDateCondition1 = $("#cmbDateCondition1").val();
        cmbDateField2 = $("#cmbDateField2").val();
        cmbDateCondition2 = $("#cmbDateCondition2").val();
        txtNgay1 = util.Trim($('#<%=txtNgay1.ClientID %>').val());
        txtNgay2 = util.Trim($('#<%=txtNgay2.ClientID %>').val());
        
        if (!isNaN(util.Trim($('#<%=txtMinSoThuLy.ClientID %>').val())))
        {
            txtMinSoThuLy = parseInt(util.Trim($('#<%=txtMinSoThuLy.ClientID %>').val()));       
        }
        if (!isNaN(util.Trim($('#<%=txtMinSoThuLy.ClientID %>').val())))
        {
            txtMaxSoThuLy = parseInt(util.Trim($('#<%=txtMaxSoThuLy.ClientID %>').val()));        
        }
        
        if (cmbField1 != "" && txtField1 != "")
        {
            txtField1 = cmbField1 + "_" + txtField1;
        } 
        else
        {
            txtField1 = "";
        }
        if (cmbField2 != "" && txtField2 != "")
        {
            txtField2 = cmbField2 + "_" + txtField2;
        }
        else
        {
            txtField2 = "";
        }
        if (cmbField3 != "" && txtField3 != "")
        {
            txtField3 = cmbField3 + "_" + txtField3;
        }
        else
        {
            txtField3 = "";
        }
        if (cmbField4 != "" && txtField4 != "")
        {
            txtField4 = cmbField4 + "_" + txtField4;
        }   
        else
        {
            txtField4 = "";
        }  
        if (cmbDateField1 != "" && cmbDateCondition1 != "" && txtNgay1 != "")
        {
            txtNgay1 = cmbDateField1 + "_" + cmbDateCondition1 + "_" + txtNgay1;
        } 
        else
        {
            txtNgay1 = "";
        }
        if (cmbDateField2 != "" && cmbDateCondition2 != "" && txtNgay2 != "")
        {
            txtNgay2 = cmbDateField2 + "_" + cmbDateCondition2 + "_" + txtNgay2;
        } 
        else
        {
            txtNgay2 = "";
        }
    }
    
    function GetFieldName(value)
    {        
        var result = "";
        switch (value)
        {
            case "1":
                result = "HoTen";
                break;
            case "2":
                result = "NoiDung";
                break;
            case "3":
                result = "DiaChi";
                break;
            case "4": 
                result = "KetQuaGiaiQuyet";
                break;
            default:
                result = "";
                break;
        }    
        
        return result;
    }
    
    function CheckValidation()
    {         
        var strMinSoThuLy = $('#<%=txtMinSoThuLy.ClientID %>').val().trim();             
        var strMaxSoThuLy = $('#<%=txtMaxSoThuLy.ClientID %>').val().trim();
        if (txtField1)
        if (cmbField1 == "" && cmbField2 == "" && cmbField3 == "" && cmbField4 == "" && 
            cmbDateField1 == "" && cmbDateCondition1 == "" && cmbDateField2 == "" && cmbDateCondition1 == "" &&
            strMinSoThuLy == "" && strMaxSoThuLy == "" && cmbLinhVuc == 0 && cmbLoaiDon == 0 && cmbDiaBan == 0)
        {
            alert("Xin vui lòng chọn điều kiện tìm kiếm!");
            return false;
        }        
        
        if (txtField1 == "" && txtField2 == "" && txtField3 == "" && txtField4 == "" && txtNgay1 == "" && txtNgay2 == "" &&
            strMinSoThuLy == "" && strMaxSoThuLy == "" && cmbLinhVuc == 0 && cmbLoaiDon == 0  && cmbDiaBan == 0)
        {
            alert("Xin vui lòng nhập giá trị tìm kiếm!");
            return false;
        }    
        
        if (cmbDateField1 != "" && cmbDateCondition1 == "")
        {
            alert("Xin vui lòng chọn điều kiện tìm kiếm của kiểu ngày!");
            $('cmbDateCondition1').focus();
            return false;
        }
        
        if (cmbDateField2 != "" && cmbDateCondition2 == "")
        {
            alert("Xin vui lòng chọn điều kiện tìm kiếm của kiểu ngày!");
            $('cmbDateCondition2').focus();
            return false;
        }               
       
        if (($('#<%=txtNgay1.ClientID%>').val() != "") && (!util.isDate($('#<%=txtNgay1.ClientID%>').val())))
        {
            alert("Ngày không hợp lệ!");
            $('#<%=txtNgay1.ClientID%>').focus();
            return false;
        }
        
        if (($('#<%=txtNgay2.ClientID%>').val() != "") && (!util.isDate($('#<%=txtNgay2.ClientID%>').val())))
        {
            alert("Ngày không hợp lệ!");
            $('#<%=txtNgay2.ClientID%>').focus();
            return false;
        }
        
        if (isNaN(strMinSoThuLy))
        {
            alert("Số thụ lý chỉ nhập giá trị số!");
            $('#<%=txtMinSoThuLy.ClientID%>').focus();
            return false;
        } 
        else
        {
            if (parseInt(util.Trim($('#<%=txtMinSoThuLy.ClientID %>').val())) < 0)
            {
                alert("Số thụ lý (từ) phải lớn hơn hoặc bằng 0!");
                $('#<%=txtMinSoThuLy.ClientID%>').focus();
                return false;
            }
        }
        
        if (isNaN(strMaxSoThuLy))
        {
            alert("Số thụ lý chỉ nhập giá trị số!");
            $('#<%=txtMaxSoThuLy.ClientID%>').focus();
            return false;
        }
        else
        {
            if (parseInt(util.Trim($('#<%=txtMaxSoThuLy.ClientID %>').val())) <= 0)
            {
                alert("Số thụ lý (đến) phải lớn hơn 0!");
                $('#<%=txtMaxSoThuLy.ClientID%>').focus();
                return false;
            }
        }
        
        return true;
    }   
    
    function isNumberKey(e)
     {  /*Grabbing the unicode value of the key that was pressed*/
        var unicode;
        var result = true;        
        try
        {   /*IE*/
            unicode = event.keyCode; 
        }
        catch(err)
        {   
            try
            { /*Netscape, Mozilla, FireFox...*/
                 unicode = event.keyCode;
            }
            catch(error)
            {  /*Other*/
                unicode = e.which;
             }
         }
        /*if the value entered is not a unicode value between 48 and 57 return false*/
        if(unicode < 48 || unicode > 57)
        {  
            result = false;
        }          
     }
     
     function OpenPrinter()
     {  
        if (isNaN(txtMinSoThuLy))
        {
            txtMinSoThuLy = 0;
        }
        if (isNaN(txtMaxSoThuLy))
        {
            txtMaxSoThuLy = 0;
        }
        var strVars = "?type=" + searchType;
        strVars += "&txt1=" + txtField1; 
        strVars += "&txt2=" + txtField2;
        strVars += "&txt3=" + txtField3;
        strVars += "&txt4=" + txtField4;
        strVars += "&txtNgay1=" + txtNgay1;
        strVars += "&txtNgay2=" + txtNgay2;
        strVars += "&txtMinSoThuLy=" + txtMinSoThuLy;
        strVars += "&txtMaxSoThuLy=" + txtMaxSoThuLy;        
        strVars += "&cmbLinhVuc=" + cmbLinhVuc;
        strVars += "&cmbLoaiDon=" + cmbLoaiDon;
        strVars += "&cmbDiaBan=" + cmbDiaBan;
       
        var strTypeReport = "Reports/LookupReportView.aspx";
        strFeatures = 'width=800px,height=600px,top=100px,left=100px,titlebar=1,menubar=0,toolbar=0,resizable=1,status=1,scrollbars=1,dependent=yes';
        window.open(strTypeReport + strVars,'_blank',strFeatures);
        return false;
    } 
    
    function resetValue()
    {
        $('#<%=hidDiaBan.ClientID %>').val(0);        
        cmbDiaBan = 0;    
    }
</script>

